package com.excilys.webservice.soap;

import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;

import com.excilys.converter.UserToUserDTOConverter;
import com.excilys.dto.AccountDTO;
import com.excilys.dto.UserDTO;
import com.excilys.model.User;
import com.excilys.service.UserService;


/**
 * Class that implements JAX-WS accounts webservice reading an user and his accounts list
 * 
 * @author excilys dev : YA
 * 
 * 
 */
@WebService(endpointInterface = "com.excilys.webservice.soap.IAccountWebService")
public class AccountWebServiceImpl implements IAccountWebService {

	@Autowired
	private UserService userService;

	@Autowired
	private UserToUserDTOConverter userConverter;

	@Override
	public UserDTO getUserByLogin(String login) {

		User user = userService.getUserByLogin(login);
		UserDTO userDto = userConverter.convert(user);

		return userDto;
	}

	@Override
	public List<AccountDTO> getUserListAccountsByLogin(String login) {
		UserDTO userDto = getUserByLogin(login);
		return userDto.getUserDTOListAccountDTO();
	}

}
